package com.some;

import java.math.BigInteger;
import java.util.Scanner;

public class JingDong {
    // 思路：根据关系推出各个节点之间的关系，然后进行递推

    public BigInteger getPath(String path, BigInteger start) {
        BigInteger res = null;

        for (char c : path.toCharArray()) {
            if (c == 'U') {
                res = start.divide(BigInteger.valueOf(2));
            }
            if (c == 'L') {
                assert res != null;
                res = res.multiply(BigInteger.valueOf(2));
            }
            if (c == 'R') {
                assert res != null;
                res = res.multiply(BigInteger.valueOf(2)).add(BigInteger.valueOf(1));
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        BigInteger X = scanner.nextBigInteger();
        String path = scanner.next();
        JingDong jingDong = new JingDong();
        System.out.println(jingDong.getPath(path, X));

    }
}
